package com.lin.util;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class RabbitUtil {
    private static ConnectionFactory myConnectionFactory;

    public  static ConnectionFactory getFactory() {
        if(myConnectionFactory == null) {
            myConnectionFactory = new ConnectionFactory();
            myConnectionFactory.setHost("119.91.33.117");
            myConnectionFactory.setUsername("root");
            myConnectionFactory.setPassword("root");
        }
        return myConnectionFactory;
    }

    public static Connection getConnection() {
        Connection connection = null;
        try {
            connection = getFactory().newConnection();
        } catch (Exception e) {
            System.out.println(e);
        }
        return connection;
    }
}
